package cn.hill4j.tool.spring.std.iop.controller;

import cn.hill4j.tool.spring.ext.iop.dynamic.DymIopClientFactory;
import cn.hill4j.tool.spring.std.iop.client.SimpleIopClientSer;
import cn.hill4j.tool.spring.std.iop.client.SimpleJdkProxyClientSer;
import cn.hill4j.tool.spring.std.iop.feign.DymFeignTest;
import cn.hill4j.tool.spring.std.iop.feign.FeignIopTest;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;


@RestController
@RequestMapping("/iop")
public class IopController {
    @Value("${server.port}")
    private Integer port;

    @Resource
    SimpleIopClientSer simpleIopClientSer;
    @Resource
    SimpleJdkProxyClientSer simpleJdkProxyClientSer;
    @Resource
    FeignIopTest feignIopTest;
    @Resource
    DymIopClientFactory<Integer, DymFeignTest> dymFeignTest;

    @GetMapping("simple")
    public String simple(){
        return port + simpleIopClientSer.out();
    }
    @GetMapping("simpleJdkProxy")
    public String simpleJdkProxy(){
        return simpleJdkProxyClientSer.out();
    }
    @GetMapping("feignIopTest")
    public String feignIopTest(){
        return feignIopTest.simple();
    }

    @GetMapping("dymFeignTest")
    public String dymFeignTest(@RequestParam("port") Integer port){
        return dymFeignTest.createIopClient(port).simple();
    }
}
